/*
 * Copyright (c) 2016.  RICOH Co.,LTD.
 * All rights reserved.
 */
package jp.co.ricoh.melody.utils;

import android.content.Context;
import android.widget.Toast;

import java.util.Date;

public class CUtil {
    private static Toast sToast;

//	private static CUtil instance;

    private CUtil() {
    }

    // for button  click
    public static long sPrelongTime = 0;

    // for button double click
    static long INTERVAL_TIME = 200;


    public static boolean isStringEmpty(String str) {
        if (str == null || str.trim().equals("")) {
            return true;
        }
        return false;
    }


    // for button double click
    public static boolean isContinue() {

        long curTime = (new Date()).getTime();

        if ((curTime - sPrelongTime) < INTERVAL_TIME) {
            return false;
        } else {
            sPrelongTime = curTime;
            return true;
        }
    }

    public static boolean isContinue(int interval_time) {

        long curTime = (new Date()).getTime();

        if ((curTime - sPrelongTime) < (interval_time <= 0 ? INTERVAL_TIME : interval_time)) {
            return false;
        } else {
            sPrelongTime = curTime;
            return true;
        }
    }

    public static void showToast(Context context, String str) {
        if (sToast != null) {
            sToast.cancel();
        }
        sToast = Toast.makeText(context, str, Toast.LENGTH_LONG);
        sToast.show();
    }
}
